<?php
$this->breadcrumbs=array(
        'Administrar',
	'Questionários',
);

$this->menu=array(
	array('label'=>'Novo Questionário', 'url'=>array('create')),
);

Yii::app()->clientScript->registerScript('search', "
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('questionario-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<h1>Administrar Questionarios</h1>

<div class="search-form">
<?php $this->renderPartial('_search',array(
	'model'=>$model,
)); ?>
</div><!-- search-form -->

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'questionario-grid',
	'dataProvider'=>$model->search(),
        'template'=>'{items}',
	'columns'=>array(
                array(
                    'name'=>'nome',
                    'value'=>'$data->nome',
                    'headerHtmlOptions'=>array('style'=>'width: 400px; height: 30px;'),
                    'htmlOptions'=>array('style'=>'text-align: left; height: 20px;'),
                ),
                array(
                    'name'=>'versao',
                    'value'=>'number_format($data->versao,1)',
                    'headerHtmlOptions'=>array('style'=>'width: 80px; height: 30px;'),
                    'htmlOptions'=>array('style'=>'text-align: center; height: 20px;'),
                ),
                array(
                    'name'=>'situacao',
                    'value'=>'$data->Situacao',
                    'headerHtmlOptions'=>array('style'=>'width: 80px; height: 30px;'),
                    'htmlOptions'=>array('style'=>'text-align: center; height: 20px;'),
                ),
                array(
                    'class'=>'CButtonColumn',
                    'template'=>'{eixos}',
                    'header'=>'Eixos',
                    'buttons'=>array(
                        'eixos'=>array(
                            'label'=>'Eixos',
                            'url'=>'Yii::app()->createUrl("admin/questionarioEixo/admin",array("q"=>$data->id_questionario))',
                            'imageUrl'=>Yii::app()->request->baseUrl . '/images/eixos.png',
                            'visible'=>'!$data->hasQuestoes($data->id_questionario)',
                        ),
                    ),
                ),
                array(
                    'class'=>'CButtonColumn',
                    'template'=>'{questoes}',
                    'header'=>'Questões',
                    'buttons'=>array(
                        'questoes'=>array(
                            'label'=>'Questões',
                            'url'=>'Yii::app()->createUrl("admin/questao/admin",array("q"=>$data->id_questionario))',
                            'imageUrl'=>Yii::app()->request->baseUrl . '/images/add.png',
                            'visible'=>'$data->hasEixos($data->id_questionario) && !$data->hasResultados($data->id_questionario)',
                        ),
                    ),
                ),
		array(
                    'class'=>'CButtonColumn',
                    'template'=>'{delete}{update}',
                    'buttons'=>array(
                        'delete'=>array(
                            'label'=>'Remover',
                            'visible'=>'!$data->situacao == 1',
                        ),
                    ),
		),
	),
)); ?>
